﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace NGUYENTHANHDONG.Excercise_lv2.Bai5
{
    public partial class Stock : Form
    {
        public Stock()
        {
            InitializeComponent();
        }

        private void btnXacNhan_Click(object sender, EventArgs e)
        {
            erpLoi.Clear();

            if(string.IsNullOrEmpty(txtKyHieuSan.Text))
            {
                erpLoi.SetError(txtKyHieuSan, "Khong dc de trong !!");
                txtKyHieuSan.Focus();
            }
            else if (string.IsNullOrEmpty(txtTenSan.Text))
            {
                erpLoi.SetError(txtTenSan, "Khong dc de trong !!");
                txtTenSan.Focus();
            }
            else if (string.IsNullOrEmpty(txtGiaDongCua.Text))
            {
                erpLoi.SetError(txtGiaDongCua, "Khong dc de trong !!");
                txtGiaDongCua.Focus();
            }
            else if (string.IsNullOrEmpty(txtGiaMoCua.Text))
            {
                erpLoi.SetError(txtGiaMoCua, "Khong dc de trong !!");
                txtGiaMoCua.Focus();
            }
            else
            {
                CONTROLLERS con = new CONTROLLERS();
                UserEntity objUser = new UserEntity(txtKyHieuSan.Text, txtTenSan.Text);

                objUser.GiaChenhLech(double.Parse(txtGiaDongCua.Text), double.Parse(txtGiaMoCua.Text));

                lsbKetQua.Items.Add("Sàn: " + objUser.KYHIEU + "chênh lêch: " + con.Chenhlech(objUser) + " %");
            }
        }
    }
}
